package DataStore
{
	import flash.display.BitmapData;
	import flash.geom.Point;
	import flash.geom.Rectangle;
	import flash.utils.Dictionary;
	import GameLogic.ENUM;
	import GameLogic.Game;
	import LoadUnit.LoadManager;
	import Map.MapManager;
	public class BmpDataPool
	{
		public static var MapPool:Dictionary = new Dictionary();
		public static var RobotPool:Dictionary = new Dictionary();
		public static var LargeSource:Dictionary = new Dictionary();
		public static var LuaEditorPool:Dictionary = new Dictionary();

		
		
		public static var LuaEditPoolIndexInit:int = 100;
		public static var LuaEditPoolIndex:int = LuaEditPoolIndexInit;
		public static var MaxImgs:int = 0;
		
		public function BmpDataPool()
		{
		}
		
		public static function AddImgToPool(_bmp:BitmapData,_name:String,_pool:Dictionary):void
		{
			_pool[_name] = _bmp;
		}
		
		/**
		 * 脚本方法，以设置需要载入的图片数量，作为结束标志
		 */
		public static function SetImgMax(_n:int):void
		{
			MaxImgs = _n;
		}
		
		public static function AddImgToEditPool(_bmp:BitmapData):void
		{
			LuaEditPoolIndex++;
			LuaEditorPool[LuaEditPoolIndex] = _bmp;
			if (LuaEditPoolIndex >= (MaxImgs + LuaEditPoolIndexInit))
			{
				Game.ImgResourceReady();
			}
		}
		
		public static function ParseMap(_id:int, _x:int, _y:int, _w:int, _h:int):void
		{
			var tile:BitmapData = new BitmapData(_w, _h);
			tile.copyPixels(LargeSource["Map"], new Rectangle(_x, _y, _w, _h), new Point(0, 0));
			MapPool[_id] = tile;
		}
		
		public static function ParseRobot(_id:int, _x:int, _y:int, _w:int, _h:int):void
		{
			var tile:BitmapData = new BitmapData(_w, _h);
			tile.copyPixels(LargeSource["Robot"], new Rectangle(_x, _y, _w, _h), new Point(0, 0));
			RobotPool[_id] = tile;
		}
		
		
	}
}